#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int n;
    cin >> n;
    int max = 0, min = 0;
    int a[n];
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        if(a[i] > a[max])
            max = i;
        if(a[i] < a[min])
            min = i;
    }
    cout << a[max] - a[min] << endl;
    return 0;
}
